import { PORT3 } from "@/api/config/servicePort";
import http from "@/api";
import { defaultParams } from "@/interface/public";
import { SoReport } from "../interface/SoReport";
import { WorkerSo } from "../interface/workerSo";

const PORT = `${PORT3}/soReport`;

interface ItemParamsProps {
  workerId: number;
  id: string;
}

interface ItemParamsProps2 {
  workerId: number | string;
  itemIds: string;
}

interface ItemParamsProps3 {
  workerId: string;
  itemIds: string;
  locationId: string;
}

// 1-保存工单
export const soReportSave = (params: SoReport.Save) => http.post(PORT + `/save`, params);

// 2-删除报工数据
export const soReportRemove = (params: ItemParamsProps) => http.post(PORT + `/remove`, params);

// 3-查询工单下的报工明细
export const soReportItemByWorker = (params: defaultParams) =>
  http.get<SoReport.SearchDetailProp>(PORT + `/itemByWorker/${params.id}`, params);

// 4-查询工单下的报工汇总
export const soReportSumByWorker = (params: defaultParams) =>
  http.get<SoReport.SearchDetailProp>(PORT + `/sumByWorker/${params.id}`);

// 5-查询时间段内报工明细
export const soReportList = (params: SoReport.ReqSearch) => http.post<SoReport.SearchDetailProp>(PORT + `/list`, params);

// 6-查询待发送入库工单
export const soReportWorkerByWaitSend = () => http.get<WorkerSo.Search[]>(PORT + `/workerByWaitSend`);

// 6.1-查询工单下待发送入库明细
export const soReportItemByWaitSend = (params: defaultParams) =>
  http.get<WorkerSo.SearchDetail>(PORT + `/itemByWaitSend/${params.id}`);

// 6.2-发送入库
export const soReportSend = (params: ItemParamsProps2) => http.post(PORT + `/send`, params);

// 7-查询待入库接收工单
export const soReportWorkerByWaitAccept = () => http.get<WorkerSo.Search[]>(PORT + `/workerByWaitAccept`);

// 7.1-查询工单下待入库接收明细
export const soReportItemByWaitAccept = (params: defaultParams) => http.get(PORT + `/itemByWaitAccept/${params.id}`);

// 7.2-入库接收
export const soReportAccept = (params: ItemParamsProps3) => http.post(PORT + `/accept`, params);

// 7.3-退回至未发料状态
export const soReportBackSend = (params: ItemParamsProps3) => http.post(PORT + `/backSend`, params);
